import { request } from '@/service/request';

// ---------- Company Begin ----------

/** get company list */
export function fetchGetCompanyList(params?: Api.Dimo.CompanySearchParams) {
  return request<Api.Dimo.CompanyList>({
    url: '/dm_company/page',
    method: 'GET',
    params
  });
}

export function fetchGetDmCompany(id: string) {
  return request<Api.Dimo.Company>({
    url: `/dm_company/${id}`,
    method: 'GET'
  });
}

/** add company info */
export function fetchAddDmCompany(data: Api.Dimo.CompanyEdit) {
  return request<boolean>({
    url: '/dm_company/',
    method: 'POST',
    data
  });
}

/** update company info */
export function fetchUpdateDmCompany(data: Api.Dimo.CompanyEdit) {
  return request<boolean>({
    url: '/dm_company/',
    method: 'PUT',
    data
  });
}

/** edit delete company */
export function fetchDeleteCompany(data: Api.Common.DeleteParams) {
  return request<boolean>({
    url: '/dm_company/',
    method: 'DELETE',
    data
  });
}

/** auth */
export function fetchAuthDmCompany(data: { id: string; status: string; authRejectReason: string }) {
  return request<boolean>({
    url: `/dm_company/auth`,
    method: 'PUT',
    data
  });
}

// 导出

export function fetchAuthDmCompanyExport(data: Api.Dimo.DmExportParams) {
  return request<boolean, 'blob' | 'json'>({
    url: `/dm_apply/export_data`,
    method: 'POST',
    data,
    responseType: 'blob'
  });
}
